Skip to content

Redesign key quantity extraction/insertion pipeline#205

Open
sbreitbart-NOAA wants to merge 2 commits intomainfrom
redesign-kqs
Open

Redesign key quantity extraction/insertion pipeline#205
sbreitbart-NOAA wants to merge 2 commits intomainfrom
redesign-kqs

Conversation

@sbreitbart-NOAA
Copy link
Collaborator

Since we've redesigned the figures and tables to be more flexible on the user's end (i.e., they can more powerfully customize what their plots show by specifying plot arguments), the existing pipeline to extract key quantities and then insert them into the captions/alt text template doesn't work for several quantities anymore. Basically, key quantities need to reflect the users' data summarization, grouping specifications, filtering, etc.

To fix this, I've begun redesigning this pipeline so that key quantities are:

  1. extracted in each plotting function (rather than most at once with write_captions(), and then the remainders with add_more_key_quants())
  2. exported to a csv listing ALL key quantities
  3. inserted into a csv with captions and alt text for figures and tables.

This pipeline should also resolve issues of key quantity calculation dependency, where the calculation of one kq depends on the prior calculation of another. If they're all calculated and stored in a single place, all can be referenced for future calculations of other quantities.

This will also facilitate sharing the kqs with SIS.

Ultimately, write_captions() and add_more_key_quants() should become redundant and removed.

@Schiano-NOAA I've just made a pilot draft focused on plot_landings(), which was a simple example. Could you please take a look and let me know if this is on the right track?

@github-actions
Copy link
Contributor

New version checklist

  • Package version in DESCRIPTION has been updated
  • Release notes have been drafted/published
  • Cheatsheet content has been updated (if applicable)
  • Cheatsheet version has been updated


### Make RDA ----
if (make_rda) {

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this chunk going to be unique to all plots? Like we won't be able to generalize this and make it more concise?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 102-108

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 102-108 are where key quantities are calculated for this plot (and I'd expect this is where each plot/table's KQs will be calculated too). The next couple of functions are where the generalization happens: in the exporting of the KQs into a csv, and the insertion of the KQs into the alt text/captions csv.

# export df with updated captions and alt text to csv
utils::write.csv(
x = caps_alttext,
file = fs::path(getwd(), "captions_alt_text.csv"),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this assumes that this file is in the wd. We either need to document that or allow it to be changed

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, for sure! I was thinking the same thing. I'll set the wd as the export folder for now but we can make that customizable later

@Schiano-NOAA
Copy link
Collaborator

Schiano-NOAA commented Mar 16, 2026

I think this is a good start! Minor questions/comments in the code base.

I also noticed that there is an extra space after the year quantity and it would be nice to have similar kqs grouped together. In the example below, the year kqs are not placed together.

image

Oh! Also, please add the new csv created to the gitignore

@Schiano-NOAA
Copy link
Collaborator

Schiano-NOAA commented Mar 16, 2026

Also, what is the use of the key_quantities.csv for the user/function? Could it be a temporary file? Maybe you can make it an excel file and use tabs or something? Just a thought in order to reduce the number of files a user has to keep track of.

@sbreitbart-NOAA
Copy link
Collaborator Author

Also, what is the use of the key_quantities.csv for the user/function? Could it be a temporary file? Maybe you can make it an excel file and use tabs or something? Just a thought in order to reduce the number of files a user has to keep track of.

It's a file where they can find their model's key quantities. I think it should be permanent, especially because it could be useful when sending information to SIS. They won't have to edit it unless they need to add or edit a key quantity, but I don't expect they'll need to do that very often

@sbreitbart-NOAA
Copy link
Collaborator Author

I think this is a good start! Minor questions/comments in the code base.

I also noticed that there is an extra space after the year quantity and it would be nice to have similar kqs grouped together. In the example below, the year kqs are not placed together.
image

Oh! Also, please add the new csv created to the gitignore

Thanks for your review! I'll group the KQs and remove that space.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants